package org.spindle.dungeon.entities;


import org.newdawn.slick.GameContainer;
import org.spindle.dungeon.Constants;
import org.spindle.dungeon.LevelProperties;

public class Lever extends GeneralEntity {

    private boolean state = true;

    @Override
    protected void initialize() {
        triggerable = true;
        staticImage = true;
        spritesList.add(Constants.SPRITE_SHEET.getSprite(4, 3));
        spritesList.add(Constants.SPRITE_SHEET.getSprite(4, 4));

        type = EntitiesConstants.LEVER;
    }

    @Override
    public void trigger(GeneralEntity by) {
        state = !state;
        if (state) {
            spriteIndex = 0;
        } else {
            spriteIndex = 1;
        }

        if (state) {
            for (GeneralEntity triger:triggerables) {

                if (triger.triggerable) {
                    triger.trigger(this);
                }
            }
        }
    }

    @Override
    public void update(GameContainer gc, LevelProperties props) {

    }
}
